package biz.obake.team.touchprotector.f;

import android.os.Build;
import android.os.Handler;
import biz.obake.team.touchprotector.g.c;
import biz.obake.team.touchprotector.tpservice.TPService;

public final class m {

    /* renamed from: a  reason: collision with root package name */
    private boolean f1640a;
    /* access modifiers changed from: private */

    /* renamed from: b  reason: collision with root package name */
    public final Handler f1641b = new Handler();
    /* access modifiers changed from: private */

    /* renamed from: c  reason: collision with root package name */
    public int f1642c;
    /* access modifiers changed from: private */

    /* renamed from: d  reason: collision with root package name */
    public int f1643d;
    private final c.b e = new a(this);
    private final Runnable f = new b(this);

    static final class a implements c.b {

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ m f1644b;

        a(m mVar) {
            this.f1644b = mVar;
        }

        public final void onRamPrefsChanged(String str) {
            if (str != null) {
                int hashCode = str.hashCode();
                if (hashCode != 175455640) {
                    if (hashCode != 1690883215 || !str.equals("Screen.State")) {
                        return;
                    }
                    if (biz.obake.team.touchprotector.d.i.b.c()) {
                        this.f1644b.l();
                    } else {
                        this.f1644b.n();
                    }
                } else if (str.equals("TPAS.FrontApp")) {
                    this.f1644b.k();
                }
            }
        }
    }

    public static final class b implements Runnable {

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ m f1645b;

        b(m mVar) {
            this.f1645b = mVar;
        }

        public void run() {
            this.f1645b.i();
            if (this.f1645b.f1642c > 0) {
                this.f1645b.j();
            }
            int i = this.f1645b.f1643d < 10 ? 1000 : this.f1645b.f1643d < 20 ? 5000 : 300000;
            if (biz.obake.team.touchprotector.d.i.b.c()) {
                this.f1645b.f1641b.postDelayed(this, (long) i);
            }
        }
    }

    /* access modifiers changed from: private */
    public final void i() {
        if (d.h.b.c.a("Locked", c.c("TPService.State"))) {
            this.f1642c = 0;
            int i = this.f1643d;
            if (i < 1000) {
                this.f1643d = i + 1;
                return;
            }
            return;
        }
        int i2 = this.f1642c;
        if (i2 < 1000) {
            this.f1642c = i2 + 1;
        }
        this.f1643d = 0;
    }

    /* access modifiers changed from: private */
    public final void j() {
        String str;
        if (Build.VERSION.SDK_INT >= 26) {
            biz.obake.team.touchprotector.c.f();
        }
        int i = this.f1642c;
        if (i == 5) {
            str = "UnlockForce";
        } else if (i == 10) {
            str = "Stop";
        } else if (i == 15) {
            k.a();
            throw new biz.obake.team.touchprotector.g.b("{B489F1A0-83FD-4F19-A01E-D4400BD4C999}");
        } else {
            return;
        }
        TPService.k(str, "SafetyMonitor");
    }

    /* access modifiers changed from: private */
    public final void k() {
        if (this.f1640a) {
            this.f1643d = 0;
            this.f1641b.removeCallbacksAndMessages((Object) null);
            this.f1641b.postDelayed(this.f, (long) 1000);
        }
    }

    /* access modifiers changed from: private */
    public final void l() {
        if (!this.f1640a) {
            this.f1640a = true;
            this.f1642c = 0;
            this.f1643d = 0;
            this.f1641b.removeCallbacksAndMessages((Object) null);
            this.f1641b.postDelayed(this.f, (long) 1000);
        }
    }

    /* access modifiers changed from: private */
    public final void n() {
        if (this.f1640a) {
            this.f1640a = false;
            this.f1641b.removeCallbacksAndMessages((Object) null);
        }
    }

    public final void m(k kVar) {
        c.e(this.e);
        l();
    }

    public final void o() {
        n();
        c.h(this.e);
    }
}
